/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-11-4 下午4:23 Created by dwzhang
 */
package com.jade.framework.base.log;

import com.jade.framework.base.util.JsonUtils;

/**
 * 采用Apache Commons Logging实现的日志，对象采用日志格式输出。
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-11-4 下午4:23
 */
public class CommonsLog implements Log
{
    private org.apache.commons.logging.Log log;

    public CommonsLog(org.apache.commons.logging.Log log)
    {
        this.log = log;
    }

    public boolean isDebugEnabled()
    {
        return log.isDebugEnabled();
    }

    public boolean isErrorEnabled()
    {
        return log.isErrorEnabled();
    }

    public boolean isFatalEnabled()
    {
        return log.isFatalEnabled();
    }

    public boolean isInfoEnabled()
    {
        return log.isInfoEnabled();
    }

    public boolean isTraceEnabled()
    {
        return log.isTraceEnabled();
    }

    public boolean isWarnEnabled()
    {
        return log.isWarnEnabled();
    }

    public void trace(Object o)
    {
        log.trace(JsonUtils.writeToString(o));
    }

    public void trace(String str, Object o)
    {
        log.trace(str + JsonUtils.writeToString(o));
    }

    public void traceThrowable(Object o, Throwable throwable)
    {
        log.trace(JsonUtils.writeToString(o), throwable);
    }

    public void debug(Object o)
    {
        log.debug(JsonUtils.writeToString(o));
    }

    public void debug(String str, Object o)
    {
        log.debug(str + JsonUtils.writeToString(o));
    }

    public void debugThrowable(Object o, Throwable throwable)
    {
        log.debug(JsonUtils.writeToString(o), throwable);
    }

    public void info(Object o)
    {
        log.info(JsonUtils.writeToString(o));
    }

    public void info(String str, Object o)
    {
        log.info(str + JsonUtils.writeToString(o));
    }

    public void infoThrowable(Object o, Throwable throwable)
    {
        log.info(JsonUtils.writeToString(o), throwable);
    }

    public void warn(Object o)
    {
        log.warn(JsonUtils.writeToString(o));
    }

    public void warn(String str, Object o)
    {
        log.warn(str + JsonUtils.writeToString(o));
    }

    public void warnThrowable(Object o, Throwable throwable)
    {
        log.warn(JsonUtils.writeToString(o), throwable);
    }

    public void error(Object o)
    {
        log.error(JsonUtils.writeToString(o));
    }

    public void error(String str, Object o)
    {
        log.error(str + JsonUtils.writeToString(o));
    }

    public void errorThrowable(Object o, Throwable throwable)
    {
        log.error(JsonUtils.writeToString(o), throwable);
    }

    public void fatal(Object o)
    {
        log.fatal(JsonUtils.writeToString(o));
    }

    public void fatal(String str, Object o)
    {
        log.fatal(str + JsonUtils.writeToString(o));
    }

    public void fatalThrowable(Object o, Throwable throwable)
    {
        log.fatal(JsonUtils.writeToString(o), throwable);
    }
}
